<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/16
 * Time: 13:16
 * used to study queue
 */

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Queue;
use App\Jobs\MakeCollection;
use App\Http\Controllers\Common;
use Illuminate\Support\Facades\DB;
use Laravel\Lumen\Routing\Controller as BaseController;

class JobController extends BaseController
{
    public function job_tender(Request $request){
        // 添加访问白名单
        $ip = Common::getip();
        $white_list = [
            '127.0.0.1'
        ];
        if(!in_array($ip,$white_list)){
            exit("您无权限进行访问");
        }
        $tender_id = intval($request->get('tender_id'));
        $user_id= intval($request->get('user_id'));
        if($tender_id <= 0 || $user_id <= 0){
            exit("参数错误");
        }
        $job = (new MakeCollection($tender_id,$user_id))->onQueue('make_collection');
        Queue::push($job);

    }
}